#!/bin/bash

# Describe:     OS status monitor
# Create Date： 2023-05-29
# Create Time:  16:55

curDate=$(date +'%Y%m%d')
logfile="$HOME/monitor.log"

if [ ! -f "$logfile" ];
then
    touch $logfile
fi

while ((1))
do
    echo "CPU 负载" >> $logfile
    uptime >> $logfile
    echo >> $logfile 

    echo "内存 使用" >> $logfile
    vm_stat -c 1 1 >> $logfile
    echo >> $logfile

    echo "IO 情况" >> $logfile
    iostat >> $logfile
    echo >> $logfile
    echo "#-------------------------------------------------------------------------" >> $logfile
    echo >> $logfile

    sleep 5
done

